-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API: Add a 'published' video parameter for related videos #4149
base: master
Are you sure you want to change the base?
Conversation
Please refactor this to query the database instead of making 20+ API requests every single time. Ideally parse the published date that is already in the watch next/recommended videos feed instead of making any extra requests. This current approach will get every instance, other than small ones, rate limited by YouTube very quickly, which will result in it being impossible to play videos at all on those instances. |
When I made this I thought that a couple of API calls wouldn't really matter, but now that I think about it, this is a very big problem. I can't get the published date from the related videos' info hash, because they only include the simpleText version. This means that it will show up as "1 hour ago" instead of "2023-10-07". Unless I can fetch the video data separately or compute it manually, I wouldn't be able to solve this issue. I will try parsing the date using the timezone data tomorrow. I will also make sure to use the database when possible. Thank you for the reply! |
I removed the need for more API calls, but keep in mind that this method wouldn't be very precise. If the video is an hour or a day old, the date would be right, but if it is a year old, it might be off by months. |
Co-authored-by: syeopite <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple more nitpicks
Co-authored-by: syeopite <[email protected]>
Co-authored-by: syeopite <[email protected]>
Bump. This PR seems to have been forgotten. |
doesnt work after the new youtube update |
@@ -245,6 +245,8 @@ module Invidious::JSONify::APIv1 | |||
json.field "lengthSeconds", rv["length_seconds"]?.try &.to_i | |||
json.field "viewCountText", rv["short_view_count"]? | |||
json.field "viewCount", rv["view_count"]?.try &.empty? ? nil : rv["view_count"].to_i64 | |||
json.field "published", rv["published"]? | |||
json.field "publishedTimeText", translate(locale, "`x` ago", rv["publishedText"].to_s.gsub(" ago", "")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things here:
- The JSON field should be
publishedText
, to match the rest of the API - The text should be translated from the time we parsed earlier. The text from the innertube (internal Youtube) API is always in english, and can't be used directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had trouble fully understanding the second request, but I improved my old code. I thought about using Time.unix(0)
when rv[published]
was nil
, but decided to make it more obvious that something is wrong, when it happens.
I also greatly apologize for the 3 month delay! I took a very long break, because of personal issues in my life.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also greatly apologize for the 3 month delay! I took a very long break, because of personal issues in my life.
No problem :) Your life is much more important than anything else!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for saying that :)
This pull request has been automatically marked as stale and will be closed in 30 days because it has not had recent activity and is much likely abandoned or outdated. If you think this pull request is still relevant and applicable, you just have to post a comment and it will be unmarked. |
Co-authored-by: Samantaz Fox <[email protected]>
This closes #3058.
It could also allow recommended videos to have their upload date shown on the
/watch
route. Let me know if you want me to add that as well.Important thing to note - this way of adding the parameter wouldn't be very precise for old videos. New videos may show up as "1 hour ago" and when that happens, the date would be accurate to the hours. Old videos may show up as "1 year ago" and that would mean that the date would only be accurate to the years. The month and day would just be chosen to be the current time's month and day, so it wouldn't even be close. But without making more API requests I don't see how this can work more accurately.